
from threading import Lock

class WORLD:
	""" represents game state, 
	"""
	lock = Lock()
	
	def __init__(self):
		
		## general
		self.our_color = 'red'	#, changed from Database at start of the match
		
		## movement 
		## + changed from brain
		self.start_x = 1237.0 		# x at start of maneuver
		self.start_y = 790.0		# y at start of maneuver
		self.pos_x = 1237.0 		# current x
		self.pos_y = 790.0			# current y
		self.velocity_x = 0.0 
		self.velocity_y = 0.0 
		self.angle = 3.1415			## angle of direction vector
		
		## time
		## + changed from brain
		self.time_passed = 0.0
		self.time_left = 90.0
		
		## goals
		self.columns_collected = 0
		self.columns_placed = 0
		self.moveable_dispanser = 5
		self.fixed_dispanser = 5
		self.buildingsite_1 = 0
		self.buildingsite_2 = 0
		self.buildingsite_3 = 0
		self.lintels_collected = 0
		self.lintels_placed = 0
		
		self.placed_columns_pattern = 'None'	# None for unknown pattern
		
		## sensors
		self.ultrasound_working = True
		self.encoders_working = True
		self.ir_guns_working = True
		
		## camera
		self.found_item_x = 0
		self.found_item_y = 0
		self.have_found_item = True
		
		## arm
		self.pack_left = False
		self.pack_right = False
		self.pack_gripper = False
		self.pack_floor_sorage = False
	
	def __getitem__(self, item):
		if self.__dict__.has_key(item):
			return self.__dict__[item]
		return None
	
	def copy(self):
		ret = WORLD()
		ret.__dict__ = self.__dict__.copy()
		return ret

sample = WORLD()
#ATTRIBUTES = [ item for item in sample.__dict__.keys() if (not item.startswith('__')) and (not callable(item)) ] ## filter out builtin attributes
#ATTRIBUTES = [ item for item in sample.__dict__.keys() if not item.startswith('__') ] ## filter out builtin attributes
ATTRIBUTES = sample.__dict__.keys()[:]

#print 'world', sample.__dict__.keys()





